package com.tdnn.fin.payments.boundary;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import com.tdnn.fin.payments.control.PaymentControl;
import com.tdnn.fin.payments.entity.Payment;

@ManagedBean
@RequestScoped
public class PaymentBoundary implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@EJB
	private PaymentControl pc;
	
	private Payment payment = new Payment();
	private List<Payment> paymentList = new ArrayList<Payment>();
	private Date dateBegin = new Date();
	private Date dateEnd = new Date();
	private Float currencyRate;
	
	@PostConstruct
	public void init(){
		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.DATE,1);
		dateBegin = cal.getTime();
		dateEnd = Calendar.getInstance().getTime();
		currencyRate=Float.valueOf(1);
	}
	
	public List<Payment> getPaymentList(){
		paymentList = pc.listCompanyPaymentByPeriod(dateBegin, dateEnd, currencyRate);
		return paymentList;
	}

	public Payment getPayment() {
		return payment;
	}

	public void setPayment(Payment payment) {
		this.payment = payment;
	}

	public void setPaymentList(List<Payment> paymentList) {
		this.paymentList = paymentList;
	}

	public Date getDateBegin() {
		return dateBegin;
	}

	public void setDateBegin(Date dateBegin) {
		this.dateBegin = dateBegin;
	}

	public Date getDateEnd() {
		return dateEnd;
	}

	public void setDateEnd(Date dateEnd) {
		this.dateEnd = dateEnd;
	}

	public Float getCurrencyRate() {
		return currencyRate;
	}

	public void setCurrencyRate(Float currencyRate) {
		this.currencyRate = currencyRate;
	}	
		
}
